package com.IT.controller;

import com.IT.entity.Medicine;
import com.IT.service.AdminFunctionService;
import com.IT.service.Impl.AdminFunctionServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet(value = "/queryMedicineController")
public class queryMedicineController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html; charset = utf-8");

        AdminFunctionService adminFunctionService = new AdminFunctionServiceImpl();

        List<Medicine> medicineList = adminFunctionService.queryMedicine();

        request.setAttribute("medicineList", medicineList);
        request.getRequestDispatcher("/admin/queryMedicine").forward(request, response);
    }
}
